package com.situ.hospital.service.impl;

import com.situ.hospital.dao.IAuthDAO;
import com.situ.hospital.dao.Impl.AuthDAOImpl;
import com.situ.hospital.pojo.Auth;
import com.situ.hospital.pojo.query.AuthQuery;
import com.situ.hospital.service.IAuthService;
import com.situ.hospital.util.PageResult;

import java.util.List;

public class AuthServiceImpl implements IAuthService {

    private IAuthDAO authDAO = new AuthDAOImpl();

    @Override
    public PageResult selectByPage(AuthQuery authQuery) {
        List<Auth> list = authDAO.selectByPage(authQuery);
        int totalCount = authDAO.selectTotalCount(authQuery);
        return new PageResult<>(0, "", totalCount, list);
    }

    @Override
    public void deleteById(int id) {
        authDAO.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        for (String id : ids) {
            authDAO.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public void add(Auth auth) {
        authDAO.add(auth);
    }

    @Override
    public Auth selectById(int id) {
        return authDAO.selectById(id);
    }

    @Override
    public void Update(Auth auth) {
        authDAO.Update(auth);
    }

    @Override
    public void updateStatus(int id, int status) {
        authDAO.updateStatus(id, status);
    }

    @Override
    public List<Auth> selectByRole(Integer role) {
        return authDAO.selectByRole(role);
    }
}
